package com.test.pattern.flyweight;

/**
 * @ClassName: Client
 * @description:
 * @author: Mr du
 * @create: 2024-02-25 21:34
 */
public class Client {

    public static void main(String[] args) {
        //初始化享元工厂
        BoxFactory factory = BoxFactory.getInstance();
        //从享元工厂中获取I图像
        AbstractBox I = factory.getKey("I");
        I.display("红色");
        AbstractBox L = factory.getKey("L");
        L.display("绿色");
        AbstractBox O = factory.getKey("O");
        O.display("蓝色");
        AbstractBox O1 = factory.getKey("O");
        O1.display("青色");
        System.out.println("两次获取到的O图形对象是否是同一个对象:"+(O == O1));
    }
}
